package com.nefu.huiyi.service.impl;

import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import  com.nefu.huiyi.entity.User;
import com.nefu.huiyi.mapper.UserMapper;
import com.nefu.huiyi.service.PasswordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class PasswordServiceImpl implements PasswordService {

    @Autowired
    private UserMapper userMapper;

    private static final String DEFAULT_PASSWORD = "123456"; // 默认密码

    @Override
    public boolean resetPasswordToDefault(Integer userId) {
        UpdateWrapper<User> wrapper = new UpdateWrapper<>();
        wrapper.eq("id", userId).set("password", DEFAULT_PASSWORD);
        return userMapper.update(null, wrapper) > 0;
    }
}